﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using VAdvantage.Logging;
using VAdvantage.Utility;
using VAdvantage.Classes;
using System.Windows.Data;


namespace VAdvantage.Framework
{
    public partial class VServer : SilverlightDesktop.Controls.Form
    {
        #region private Variable
        bool isServerRunning = false;
        VLogger log = null;
        // static ViennaServerMgr s_serverMgr = null;

        #endregion

        /// <summary>
        /// Default Constructor
        /// </summary>
        public VServer()
        {
            InitializeComponent();
            Grid();
            vdgRequest.ItemsSource = ServerData.GetServerDataList();
            log = VLogger.GetVLogger(GetType().FullName);
        }

        /// <summary>
        /// Craete grid column 
        /// </summary>
        private void Grid()
        {
            DataGridCheckBoxColumn checkBoxColumn = new DataGridCheckBoxColumn();
            checkBoxColumn.Header = "#";
            checkBoxColumn.Binding = new Binding("Ischeck");
            
            vdgRequest.Columns.Add(checkBoxColumn);

            DataGridTextColumn Process = new DataGridTextColumn();
            Process.Header = "Process";
            Process.Binding = new Binding("Process");
            vdgRequest.Columns.Add(Process);

            DataGridTextColumn Port = new DataGridTextColumn();
            Port.Header = "Port";
            Port.Binding = new Binding("Port");
            vdgRequest.Columns.Add(Port);

            DataGridTextColumn Status = new DataGridTextColumn();
            Status.Header = "Status";
            Status.Binding = new Binding("Status");
            vdgRequest.Columns.Add(Status);

            DataGridTextColumn StartedAt = new DataGridTextColumn();
            StartedAt.Header = "StartedAt";
            StartedAt.Binding = new Binding("StartedAt");
            vdgRequest.Columns.Add(StartedAt);
            vdgRequest.AutoGenerateColumns = false;
        
        }

       
        private void btnStart_Click(object sender, RoutedEventArgs e)
        {

        }

        private void btnStop_Click(object sender, RoutedEventArgs e)
        {

        }
    }

    public class ServerData
    {
        #region private Variable


        static String[] mProcessCode = 
        {
            "AS",
            "SP",
            "AP",
            "AL",
            "RP",
            "WP",
            "MS"
        };

      static  String[] mProcess = 
        {
            "Application Server",
            "Scheduler",
            "Account Processor",
            "Alert Processor",
            "Request Processor",
            "Workflow Processor",
            "MSMQ Server"
        };

      static String[] mPOrt = 
        {
            "2090",
            "Default",
            "Default",
            "Default",
            "Default",
            "Default",
            "Default"
        };

      static String[] mStatus = 
        {
            "Stopped",
            "Stopped",
            "Stopped",
            "Stopped",
            "Stopped",
            "Stopped",
            "Stopped"
        };


        #endregion

        public Boolean Ischeck { get; set; }
        public VAdvantage.Model.ValueNamePair Process { get; set; }
        public String Port { get; set; }
        public String Status { get; set; }
        public String StartedAt { get; set; }

        public ServerData(Boolean ischeck, VAdvantage.Model.ValueNamePair process, String port, String status, String startedAt)
        {
            this.Ischeck = ischeck;
            this.Process = process;
            this.Port = port;
            this.Status = status;
            this.StartedAt = startedAt;
        }

      
        public static  List<ServerData> GetServerDataList()
        {

            List<ServerData> obj = new List<ServerData>();
            for (int i = 0; i <= mProcess.Length - 1; i++)
            {
                obj.Add(new ServerData(true, new Model.ValueNamePair(mProcessCode[i], mProcess[i]), mPOrt[i], mStatus[i], ""));

            }

            return obj;
        }
    }


}
